package ltd.dujiabao.dex.rabbitmq.exe;

import org.springframework.amqp.rabbit.core.RabbitTemplate;

import ltd.dujiabao.dex.core.DelayJobEntity;
import ltd.dujiabao.dex.core.emitter.Emitter;
import ltd.dujiabao.dex.core.emitter.EmitterFactory;
import ltd.dujiabao.dex.core.ExecutorType;

/**
 * @author : DuJiabao
 * @Project : common-delay-executor
 * @Time : 2024/3/26 23:12
 * @Desc :
 */
public class RabbitEmitterFactory implements EmitterFactory {
    private final RabbitTemplate rabbitTemplate;

    public RabbitEmitterFactory(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    @Override
    public Emitter getEmitter(DelayJobEntity delayJob) {
        return new RabbitEmitter(delayJob, rabbitTemplate);
    }

    @Override
    public ExecutorType executorType() {
        return ExecutorType.RABBITMQ;
    }
}
